// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router'

import axios from 'axios'
import { post, fetch, patch, put } from 'services/index'
//定义全局变量
Vue.prototype.$post = post;
Vue.prototype.$fetch = fetch;
Vue.prototype.$patch = patch;
Vue.prototype.$put = put;

Vue.config.productionTip = false

// import Vant from 'vant';
import 'vant/lib/vant-css/index.css';
// Vue.use(Vant);
import { Toast, Dialog, Tab, Tabs, Popup, Picker, Field, Button } from 'vant';
Vue.use(Toast);
Vue.use(Dialog);
Vue.use(Tab).use(Tabs).use(Popup).use(Picker).use(Field).use(Button);

// 设置html字体大小
document.documentElement.style.fontSize = window.innerWidth / 21.6 + 'px'

// 定义全局变量
window.xmview = {
    showAlert(title = '', content, confirmText = '确认', fn) {
        Dialog.alert({
            title: title,
            message: content,
            confirmButtonText: confirmText
        }).then(() => {
            // on close
            fn()
        });
    },
    showToast(msg) {
        Toast(msg);
    },
    showLoading(msg) {
        Toast.loading({
            duration: 0,
            mask: true,
            message: msg
        });
    },
    hideLoading() {
        Toast.clear();
    }

}
window.xmrouter = router
    // window.xmconfig = {
    //     apiHost: config.apiHost,
    // }

/* eslint-disable no-new */
new Vue({
    el: '#app',
    router,
    render: h => h(App)
})

export default {}